﻿<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    http://topic.csdn.net/u/20090819/08/c6b95cfb-a8e7-44ac-8ddc-d6e98889a8f0.html?seed=1147293859&r=59175147#r_59175147
        <asp:DropDownList ID="ddl" runat="server" onchange="ddl_Change(this)">
            <asp:ListItem></asp:ListItem>
            <asp:ListItem style="color:Gray">1</asp:ListItem>
            <asp:ListItem style="color:Gray">--1.1</asp:ListItem>
            <asp:ListItem  _canSelect="1">----1.1.1</asp:ListItem>
            <asp:ListItem style="color:Gray">--1.2</asp:ListItem>
             <asp:ListItem style="color:Gray">2</asp:ListItem>
            <asp:ListItem style="color:Gray">--2.1</asp:ListItem>
            <asp:ListItem  _canSelect="1">----2.1.1</asp:ListItem>
            <asp:ListItem style="color:Gray">--2.2</asp:ListItem>
        </asp:DropDownList>
        <script type="text/ecmascript">
            function ddl_Change(sender) {
                var selectedOption = sender.options[sender.selectedIndex];
                if (selectedOption._canSelect) {
                    sender._lastSelectedIndex = sender.selectedIndex;
                } else {
                sender.selectedIndex = sender._lastSelectedIndex != undefined ? sender._lastSelectedIndex : 0;
                alert("you can not select this item");
                }
            }
        </script>
        
    </div>
    </form>
</body>
</html>
